package mapper.entity;

import server.HttpServlet;

import java.util.List;

/**
 * Created by Ju·Felix on 2020/5/17.
 */
public class Context {
    private String name;
    private List<Wrapper> wrapperList;

    public Context() {
    }

    public Context(String name, List<Wrapper> wrapperList) {
        this.name = name;
        this.wrapperList = wrapperList;
    }

    public HttpServlet findHttpServlet(String urlPattern) {
        // 第三层：过滤wrapper，获取HttpServlet
        for (Wrapper wrapper : wrapperList) {
            if (wrapper.getUrlPattern().equals(urlPattern)) {
                return wrapper.getServlet();
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Wrapper> getWrapperList() {
        return wrapperList;
    }

    public void setWrapperList(List<Wrapper> wrapperList) {
        this.wrapperList = wrapperList;
    }
}
